Open
Conversation
codenamev
commented
Mar 6, 2020
| } else if (RB_TYPE_P(rb_val, T_TRUE) || RB_TYPE_P(rb_val, T_FALSE)) { | ||
| error = git_config_set_multivar(config, key, "$^", (rb_val == Qtrue) ? "true" : "false"); | ||
| } else if (FIXNUM_P(rb_val)) { | ||
| char str_value[32]; |
Author
There was a problem hiding this comment.
I took this snippet from the libgit2 source. I'm not entirely sure this is the best way to do this conversion, but I figured I'd at least mimic the behavior. There are some performance enhancements related to windows systems for snprintf that were not ported over (because I have no idea how that works).
This method allows you to set multiple values for the same key in a
particular config, similar to `git config --add "include.path" some/path`.
For example, I have a git config with an existing `include.path` value:
```
$ cat ~/src/opensource/rugged/.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = [email protected]:codenamev/rugged.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "vendor/libgit2"]
active = true
url = https://github.com/libgit2/libgit2.git
[include]
path = /Users/codenamev/.gitconfig.reflow
```
With `Rugged::Config#add` I can set another value for `include.path`
without overwriting the existing value:
```
ruby -I lib -rrugged -e'\
config = Rugged::Repository.new("/Users/codenamev/src/opensource/rugged").config;
config.add("include.path", "/Users/codenamev/.gitconfig.extras");
p config.get_all("include.path")'
["/Users/codenamev/.gitconfig.reflow", "/Users/codenamev/.gitconfig.extras"]
```
References libgit2#725
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This method allows you to set multiple values for the same key in a
particular config, similar to
git config --add "include.path" some/path.For example, I have a git config with an existing
include.pathvalue:With
Rugged::Config#addI can set another value forinclude.pathwithout overwriting the existing value:
References #725